package com.aikon.wht.multiThread;

import com.google.common.util.concurrent.MoreExecutors;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.concurrent.ExecutorService;

/**
 * @author haitao.wang
 */
public class TestOfMoreExecutors {

    public static void main(String[] args) {
        ExecutorService es = MoreExecutors.newDirectExecutorService();
        Thread t = new Thread();
        SS ss = new SS(1);
        for (int i = 0; i < 10; i++)
            es.submit(new TT(ss));
    }


    public static class TT implements Runnable {

        SS ss;

        public TT(SS ss) {
            this.ss = ss;
        }

        @Override
        public void run() {
            ss.i++;
            System.out.println(Thread.currentThread().getName() + " " + ss.i);
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class SS {
        int i;
    }
}
